<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset="utf-8">
<title>帐号管理 | 设置渠道</title>
<@fm.header />
<style>
.apk-info-basic label {
	font-size: 12px;
	float:left;
	margin:2px;
	width:200px;
	height:20px;
}
</style>
</head>
<body>
<div class="easyui-layout" style="text-align: center; height: 270px;" fit="true">
	<div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
	    <div id="main-2">
			<span class="apk-info-basic">
				<#if channelList?exists>
				<#list channelList as channel>
					<label><input type="checkbox" name="resId" value="${channel.channelId}"
					<#if userList?exists>
						<#list userList as uc>
							<#if channel.channelId == uc>checked</#if>
						</#list>
					</#if>
					>${channel.channelId}</label>
				</#list>
				</#if>
			</span>
	    </div>
	</div>
	<div region="south" border="false" style="text-align: center; ">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="allSelect()">全选</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="killAllSelect()">取消全选</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm1('/user/${userId}/channel')">提交</a>
	</div>
</div>
<form id="ff" method="post">
	<input type="hidden" name="resObj" value="">
</form>
<script>
function submitForm1(url){
	// 处理数据及验证
	var f_str = '';
	$('#main-2').find('input[type="checkbox"]:checked').map(function(idx, ele){
		f_str +=","+ $(ele).val();
	});
	if(!f_str){
		showMsg(market.content.title, market.content.tips, alert);
	}else{
		$('#ff').form(
		'submit',
		{
			url : url,
			onSubmit : function() {
			    $("input[name='resObj']").val(f_str);
				var flag = true;
				if (flag) {
					showProcess(true, market.content.title,	market.content.submitting);
				}
				return flag;
			},
			success : function(data) {
				showProcess(false);
				var data = eval('(' + data + ')');
				if (data.return_code == '1') {
					top.showMsg(market.content.title, data.return_msg, alert);
					if (parent !== undefined) {
						if ($.isFunction(parent.reloadParent)) {
							parent.reloadParent.call();
							parent.closeMyWindow();
						} else {
							parent.$("#tt").datagrid('reload');
							parent.closeMyWindow();
						}
					}
				} else {
					$.messager.alert(market.content.title, data.return_msg);
				}
			},
			onLoadError : function() {
				showProcess(false);
				$.messager.alert(market.content.title, market.content.networkError);
			}
		});
	}
}
function allSelect(){
	$('#main-2').find('input[type="checkbox"]').attr("checked",true);
}
function killAllSelect(){
	$('#main-2').find('input[type="checkbox"]').attr("checked",false);
}
</script>
</body>
</html>